package proxystatic;

//静态代理
public class StaticProxy {
    public static void main(String[] args) {
        You you=new You();//你要结婚

        new Thread( ()-> System.out.println("我爱你")).start();

        new WeddingCompany(new You()).HappyMarry();

//        you.HappyMarry();

//        WeddingCompany weddingCompany =new WeddingCompany(new You());
//        weddingCompany.HappyMarry();
}
}
interface Marry {

    void HappyMarry();
}

//真实角色
class You implements Marry {
    @Override
    public void HappyMarry() {
        System.out.println("老师结婚了，超开心");
    }
}

//代理角色
class WeddingCompany implements Marry {

    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();//真实结婚
        after();
    }

    private void after() {
        System.out.println("结婚之后收尾款");
    }

    private void before() {
        System.out.println("结婚前布置婚礼现场");
    }
}

